/*
 * This file contains a subset of the RPC protocol for NFS, as described in
 * RFC 1813:
 *
 * https://www.ietf.org/rfc/rfc1813.txt
 *
 * Apart from omitting parts of the protocol that are not needed, only one
 * modification has been made:
 *
 * 1. The upper bound of the opaque data in an fhandle3 has been omitted,
 *    to demonstrate a buffer overflow in Mac OS version 10.13.5.
 */

struct fhandle3 {
  opaque data<>;  /* Note: upper bound deliberately omitted */
};

enum mountstat3 {
  MNT3_OK = 0,                 /* no error */
  MNT3ERR_PERM = 1,            /* Not owner */
  MNT3ERR_NOENT = 2,           /* No such file or directory */
  MNT3ERR_IO = 5,              /* I/O error */
  MNT3ERR_ACCES = 13,          /* Permission denied */
  MNT3ERR_NOTDIR = 20,         /* Not a directory */
  MNT3ERR_INVAL = 22,          /* Invalid argument */
  MNT3ERR_NAMETOOLONG = 63,    /* Filename too long */
  MNT3ERR_NOTSUPP = 10004,     /* Operation not supported */
  MNT3ERR_SERVERFAULT = 10006  /* A failure on the server */
};

program NFS_PROGRAM {
  version NFS_V3 {
    void
      NFSPROC3_NULL(void) = 0;
  } = 3;
} = 100003;

const MNTPATHLEN = 1024;
typedef string dirpath<MNTPATHLEN>;

struct mountres3_ok {
  fhandle3 fhandle;
  int auth_flavors<>;
};

const MNT_OK = 0;

union mountres3 switch (mountstat3 fhs_status) {
case MNT_OK:
  mountres3_ok  mountinfo;
default:
  void;
};

program MOUNT_PROGRAM {
  version MOUNT_V3 {
    void      MOUNTPROC3_NULL(void) = 0;
    mountres3 MOUNTPROC3_MNT(dirpath) = 1;
  } = 3;
} = 100005;
